Importing the dependencies
[ ]
[ ]
Data collection and processing
[ ]
[ ]
[ ]
[ ]
(1025, 14)
[ ]
<class
'pandas.core.frame.DataFrame'>
RangeIndex: 1025
entries, 0 to 1024
Data columns (total 14
columns):
#
Column Non-Null Count Dtype
--- ------
-------------- -----
0
age 1025 non-null int64
1
sex 1025 non-null int64
2
cp 1025 non-null int64
3
trestbps 1025 non-null int64
4
chol 1025 non-null int64
5
fbs 1025 non-null int64
6
restecg 1025 non-null int64
7
thalach 1025 non-null int64
8
exang 1025 non-null int64
9
oldpeak 1025 non-null float64
10
slope 1025 non-null int64
11
ca 1025 non-null int64
12
thal 1025 non-null int64
13
target 1025 non-null int64
dtypes: float64(1),
int64(13)
memory usage: 112.2 KB
[ ]
age 0
sex 0
cp 0
trestbps 0
chol 0
fbs 0
restecg 0
thalach 0
exang 0
oldpeak 0
slope 0
ca 0
thal 0
target 0
dtype: int64
[ ]
[ ]
1 526
0 499
Name: target, dtype:
int64
1--> defective heart 0--> healthy heart
Splitting the features and target
[ ]
[ ]
age
sex cp trestbps
chol fbs restecg
thalach exang oldpeak
\
0 52
1 0 125
212 0 1
168 0 1.0
1 53
1 0 140
203 1 0
155 1 3.1
2 70
1 0 145
174 0 1
125 1 2.6
3 61
1 0 148
203 0 1
161 0 0.0
4 62
0 0 138
294 1 1
106 0 1.9
... ...
... .. ...
... ... ...
... ... ...
1020 59
1 1 140
221 0 1
164 1 0.0
1021 60
1 0 125
258 0 0
141 1 2.8
1022 47
1 0 110
275 0 0
118 1 1.0
1023 50
0 0 110
254 0 0
159 0 0.0
1024 54 1
0 120 188
0 1 113
0 1.4
slope
ca thal
0 2
2 3
1 0
0 3
2 0
0 3
3 2
1 3
4 1
3 2
... ...
.. ...
1020 2
0 2
1021 1
1 3
1022 1
1 2
1023 2
0 2
1024 1
1 3
[1025 rows x 13
columns]
[ ]
0 0
1 0
2 0
3 0
4 0
..
1020 1
1021 0
1022 0
1023 1
1024 0
Name: target, Length:
1025, dtype: int64
Splitting the data into training data & test data
[ ]
[ ]
(1025, 13) (820, 13)
(205, 13)
Model Training
Logistic Regression
[ ]
[ ]
Model Evaluation
Accuracy score
[ ]
[ ]
Accuracy on Training
data : 0.8524390243902439
[ ]
[ ]
Accuracy on Test data
: 0.8048780487804879
Building predictive system
[ ]
[0]
The Person has a
healthy heart
/usr/local/lib/python3.10/dist-packages/sklearn/base.py:439:
UserWarning: X does not have valid feature names, but LogisticRegression was
fitted with feature names
warnings.warn(
[ ]
[1]
The Person has heart
disease
/usr/local/lib/python3.10/dist-packages/sklearn/base.py:439:
UserWarning: X does not have valid feature names, but LogisticRegression was
fitted with feature names
warnings.warn(
[ ]